from user import models
from rest_framework import serializers

#用户模型的序列化
class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.UserModel
        fields = '__all__'

class HeadImage(serializers.Serializer):
    file=serializers.ImageField()
    def validate(self, attrs):
        #print(attrs)
        if attrs["file"].size>1024*1024*2:
            raise serializers.ValidationError("文件大小不能超过2M")
        return attrs

class UserSer(serializers.ModelSerializer):
    class Meta:
        model=models.UserModel
        fields = ["id","nickname","account"]
class FollowSerializers(serializers.ModelSerializer):
    class Meta:
        model=models.FollowModel
        fields = "__all__"
